<template>
  <div v-loading="loading">
    <!-- {{this.auditList.moduleId}} -->
    <!-- 班前班后会管理 -->
    <template v-if="auditList.moduleId === 36">
      <el-form label-width="190px">
        <el-form-item label="班组：">
          {{ detailsList.groupName }}
        </el-form-item>
        <el-form-item label="缺席人员：">
          <template v-if="detailsList.notJoinedPersons">
            <el-tag class="input_tag" v-for="tag in detailsList.notJoinedPersons" :key="tag.id" type="danger">
              <span>{{tag.name}}</span>
            </el-tag>
          </template>
        </el-form-item>
        <el-form-item label="上传文件：">
          <template v-if="detailsList.files">
            <span v-for="(item, index) in detailsList.files" :key="index">
              <HuFileBut v-if="item.fileInfo" :path="item.fileInfo.previewPath" :name="item.fileInfo.originalName" />
            </span>
          </template>
        </el-form-item>
      </el-form>
      <h2 style="font-size: 18px; padding-bottom: 10px; font-weight: 700">
        工作任务
      </h2>
      <hu-table :tableData="detailsList.tasks" :tableCol="tableCol0">
        <template #workResponsible={row}>
          <span v-if="row.workResponsible">
            {{row.workResponsible.name}}
          </span>
        </template>
        <template #workMembers={row}>
          <span v-if="row.workMembers">
            {{row.workMembers.map(e => e.name).join(',')}}
          </span>
        </template>
      </hu-table>
    </template>
  </div>
</template>

<script>
import * as http from "@/api/audit/examine/components.js";
export default {
  components: {
  },
  props: {
    auditList: {
      type: Object,
      require: true,
    },
  },
  watch: {
    auditList: {
      handler() {
        this.getList();
      },
      immediate: true,
    },
  },
  data() {
    return {
      indexTabs: "1",
      tableCol0: [
        {
          title: "序号",
          type: "index",
          width: "55",
        },
        {
          title: "工作名称",
          key: "taskName",
        },
        {
          title: "危害后果",
          key: "harmfulResult",
        },
        {
          title: "风险等级",
          key: "riskLevelName",
          // width: "170",
        },
        {
          title: "工作负责人",
          slot: "workResponsible",
        },
        {
          title: "工作班成员",
          slot: "workMembers",
        },
      ],
      tableCol2: [
        {
          title: "序号",
          type: "index",
          width: "55",
        },
        {
          title: "工器具分类",
          key: "toolTypeName",
        },
        {
          title: "工器具名称",
          key: "toolName",
        },
        {
          title: "工器具数量",
          key: "toolNumber",
        },
        {
          title: "工器具编号",
          key: "toolCode",
        },
        {
          title: "年检单位",
          key: "yearCheckUnit",
        },
        {
          title: "年检时间",
          key: "yearCheckDate",
        },
        {
          title: "外观检查结果",
          key: "checkResult",
        },
      ],
      tableCol3: [
        {
          title: "序号",
          type: "index",
          width: "55",
        },
        {
          title: "附件类型",
          key: "fileTypeName",
        },
        {
          title: "附件",
          slot: "fileItem",
        },
        {
          title: "证件有效截止时间",
          key: "expireDate",
        },
        {
          title: "备注",
          key: "remark",
        },
      ],
      detailsList: {},
      businessKey: undefined,
    };
  },
  created() {},
  methods: {
    getList() {
      this.loading = true;
      if (this.auditList.moduleId) {
        this["getList" + this.auditList.moduleId]();
      }
    },
    getList36() {
      http.getList36(this.auditList.businessKey).then(({ result }) => {
        this.detailsList = result;
        this.loading = false;
      });
    },
    getList40() {
      http.getList40(this.auditList.businessKey).then(({ result }) => {
        this.detailsList = result;
        this.loading = false;
      });
    },
    getList111() {
      http.getList111(this.auditList.businessKey).then(({ result }) => {
        this.detailsList = result;
        this.loading = false;
      });
    },
    getList112() {
      http.getList112(this.auditList.businessKey).then(({ result }) => {
        this.detailsList = result;
        this.loading = false;
      });
    },
    getList113() {
      http.getList113(this.auditList.businessKey).then(({ result }) => {
        this.detailsList = result;
        this.loading = false;
      });
    },
    getList127() {
      http.getList7(this.auditList.businessKey).then(({ result }) => {
        this.detailsList = result;
        this.loading = false;
      });
    },
    getList128() {
      http.getList8(this.auditList.businessKey).then(({ result }) => {
        this.detailsList = result;
        this.loading = false;
      });
    },
    getList131() {
      http.getList9(this.auditList.businessKey).then(({ result }) => {
        this.detailsList = result;
        this.loading = false;
      });
    },
    getList132() {
      let params = atob(this.auditList.businessKey); //.split(',')
      this.businessKey = params;
      this.loading = false;
      this.$nextTick(() => {
        this.$refs["table" + this.indexTabs].getList();
      });

      console.log(params, this.businessKey);
    },
    getList133() {
      http.getList133(this.auditList.businessKey).then(({ result }) => {
        this.detailsList = result ? result : {};
        this.loading = false;
      });
    },
    getList153() {
      http.getList153(this.auditList.businessKey).then(({ result }) => {
        this.detailsList = result ? result : {};
        this.loading = false;
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.input_tag {
  margin-right: 5px;
}
</style>
